package pl.lodz.p.kipme;

import java.util.Date;
import java.util.List;

import javax.jws.WebService;

import pl.lodz.p.kipme.bo.Category;
import pl.lodz.p.kipme.bo.Order;
import pl.lodz.p.kipme.bo.Product;
import pl.lodz.p.kipme.bo.ProductInfo;
import pl.lodz.p.kipme.bo.ProductType;
import pl.lodz.p.kipme.bo.Transaction;
import pl.lodz.p.kipme.dao.OrderDAO;
import pl.lodz.p.kipme.dao.ProductDAO;
import pl.lodz.p.kipme.dao.TransactionDAO;
import pl.lodz.p.kipme.exception.BusinessException;

@WebService(endpointInterface = "pl.lodz.p.kipme.CentralService", serviceName = "centralService")
public class CentralServiceImpl implements CentralService {

	private ProductDAO productDAO;
	private OrderDAO orderDAO;
	private TransactionDAO transactionDAO;

	@Override
	public List<Order> checkWaitingOrders() {
		List<Order> list = orderDAO.getWaitingOrders();
		return list;
	}

	@Override
	public void updateOrderState(Order order) throws BusinessException {
		orderDAO.updateOrder(order);
	}

	@Override
	public List<Transaction> getTransactionSummary() {
		List<Transaction> list = transactionDAO.getAllTransaction();
		return list;
	}

	@Override
	public List<ProductInfo> getProductInfo() {
		return productDAO.getProductInfoList();
	}

	@Override
	public List<Category> getCategoryList() {
		return productDAO.getCategories();
	}

	@Override
	public List<ProductType> getProductTypeList() {
		return productDAO.getProductTypes();
	}

	@Override
	public Product getProductByProductCode(String productCode) {
		return productDAO.getProductByCode(productCode);
	}

	@Override
	public List<Product> getProductsByCategory(String categoryCode) {
		return productDAO.getProductsByCategory(categoryCode);
	}

	@Override
	public List<Product> getProductsByType(String typeCode) {
		return productDAO.getProductsByType(typeCode);
	}

	@Override
	public List<Transaction> getTransactions(Date startDate, Date endDate) {
		return transactionDAO.getTransactionsBetweenDates(startDate, endDate);
	}

	@Override
	public List<Transaction> getTransactionsByProductCode(String productCode) {
		return transactionDAO.getTransactionsByProductCode(productCode);
	}

	public ProductDAO getProductDAO() {
		return productDAO;
	}

	public void setProductDAO(ProductDAO productDAO) {
		this.productDAO = productDAO;
	}

	public OrderDAO getOrderDAO() {
		return orderDAO;
	}

	public void setOrderDAO(OrderDAO orderDAO) {
		this.orderDAO = orderDAO;
	}

	public TransactionDAO getTransactionDAO() {
		return transactionDAO;
	}

	public void setTransactionDAO(TransactionDAO transactionDAO) {
		this.transactionDAO = transactionDAO;
	}

}
